import React from "react";
import { Button, Space, Table } from "antd";
import dayjs from "dayjs";
function TableList({
  list,
  editBtnShow,
  delBtnShow,
  page,
  pageSize,
  onChange = () => {},
  total,
  delFn,
  editFn,
}) {
  const columns = [
    {
      title: "ID",
      dataIndex: "id",
    },
    {
      title: "姓名",
      dataIndex: "name",
    },
    {
      title: "岗位",
      dataIndex: "job",
    },
    {
      title: "地址",
      dataIndex: "schema_name",
    },
    {
      title: "状态",
      dataIndex: "status",
    },
    {
      title: "时间",
      dataIndex: "create_time",
      render(_, record) {
        return dayjs(record.create_time).format("YYYY-MM-DD");
      },
    },
    {
      title: "操作",
      render(_, record) {
        return (
          <Space>
            {editBtnShow && (
              <Button
                onClick={() => {
                  editFn(record);
                }}
              >
                编辑
              </Button>
            )}
            {delBtnShow && (
              <Button
                danger
                onClick={() => {
                  delFn(record);
                }}
              >
                删除
              </Button>
            )}
          </Space>
        );
      },
    },
  ];
  return (
    <div>
      <Table
        dataSource={list}
        columns={columns}
        rowKey={"id"}
        pagination={{
          pageSize: pageSize,
          page: page,
          onChange: onChange,
          total: total,
        }}
      />
      ;
    </div>
  );
}

export default React.memo(TableList);
